package com.codedancer.campus.client.handler.impl.user;

import static com.codedancer.campus.enums.SystemMessageType.FOLLOW_USER;

import cn.hutool.core.bean.BeanUtil;
import com.codedancer.campus.client.handler.SystemMessageHandler;
import com.codedancer.campus.client.service.model.SystemMessageMqParamModel;
import com.codedancer.campus.enums.SystemMessageType;
import com.codedancer.campus.mapper.SystemMessageMapper;
import com.codedancer.campus.po.SystemMessage;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Data
@Component
@Slf4j
public class UserFollowSystemMessageHandler implements SystemMessageHandler {

    private final SystemMessageType messageType = FOLLOW_USER;
    @Autowired
    private SystemMessageMapper systemMessageMapper;


    /**
     * 保存系统消息
     *
     * @param systemMessageMqParamModel
     */
    @Override
    public void saveSystemMessage(SystemMessageMqParamModel systemMessageMqParamModel) {
        SystemMessage systemMessage = BeanUtil.copyProperties(systemMessageMqParamModel,
            SystemMessage.class);
        systemMessageMapper.insert(systemMessage);
    }

    @Override
    public SystemMessageType getSystemMessageType() {
        return messageType;
    }
}
